﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
using AppManage.Data.Functions;
using AppManage.Data.Items;
using AppManage.Data.Modules;
using AppManage.Data.Permissions;
using AppManage.Data.Roles;
using AppManage.Data.Users;
using AppManage.EntityFramework.Mapping;

namespace AppManage.EntityFramework
{
    public class SystemManageDbContext : DbContext
    {
        //DbSet to this
        public virtual DbSet<Function> Functions { get; set; }
        public virtual DbSet<Item> Items { get; set; }
        public virtual DbSet<Module> Modules { get; set; }
        public virtual DbSet<Permission> Permissions { get; set; }
        public virtual DbSet<Role> Roles { get; set; }
        public virtual DbSet<UserRole> UserRoles { get; set; }
        public virtual DbSet<User> Users { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.Configurations.Add(new FunctionMap());
            modelBuilder.Configurations.Add(new ItemMap());
            modelBuilder.Configurations.Add(new ModuleMap());
            modelBuilder.Configurations.Add(new PermissionMap());
            modelBuilder.Configurations.Add(new RoleMap());
            modelBuilder.Configurations.Add(new UserRoleMap());
            modelBuilder.Configurations.Add(new UserMap());
        }
    }
}
